<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商品编辑</title>
    <!-- layUI的核心CSS文件 -->
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/css/layui.css"/>
    <!-- layUI的核心JS文件 -->
    <script src="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/layui.js" type="text/javascript"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/static/js/jQuery.js" charset="UTF-8"></script>
    <style type="text/css">
        .layui-table-cell {
            height: 50px;
            line-height: 36px;
        }
    </style>
</head>
<body>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        let element = layui.element;
    });
    layui.use('form', function () {
        let form = layui.form;
    });
</script>
<!-- 头部导航栏 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><a style="color: #009688;">龙洞闲置购物系统</a></div>

        <!-- 头部区域（可配合layui已有的水平导航） -->

        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item">
                <a href="ShowALLGoods">首页</a>
            </li>
            <li class="layui-nav-item">
                商品编辑
            </li>
        </ul>
        <%@include file="../common/head.jsp" %>
    </div>
</div>
<%-- 商品信息 --%>
<div class="layui-row">
    <div class="layui-col-md6 layui-col-lg-offset3"
         style="margin-top: 80px;border: 1px solid gray; padding: 20px;margin-bottom: 20px;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>商品编辑</legend>
        </fieldset>

        <form class="layui-form layui-form-pane" action="updateGoods" enctype="multipart/form-data" method="post">
            <input type="hidden" name="gid" value="${goods1.gid}">
            <input id="number" type="hidden" name="gnumber" value="1">
            <input id="uid" type="hidden" name="guid" value="${user.uid}">
            <input id="uname" type="hidden" name="guname" value="${user.uname}">
            <input id="img_path" type="hidden" name="gimg_path" value="${goods1.gimg_path}">
            <input id="tinyint" type="hidden" name="gtinyint" value="1">

            <%-- 图片 --%>
            <div class="layui-col-lg-offset1 layui-col-md10" style="margin-top:10px;">
                <c:if test="${empty goods1.gimg_path}">
                    <img src="${pageContext.request.contextPath}/static/images/white1.jpg"
                         style="width: 150px; height: 150px;margin-left: 15px;" alt="图片加载失败">
                </c:if>
                <c:if test="${not empty goods1.gimg_path}">
                    <img src="${goods1.gimg_path}"
                         style="width: 150px; height: 150px;margin-left: 15px;" alt="图片加载失败">
                </c:if>
                <input type="file" name="imgfile">
            </div>
            <%-- 商品名 --%>
            <div class="layui-col-lg-offset1 layui-col-md10" style="margin-top:10px;">
                <label class="layui-form-label">商品名</label>
                <div class="layui-input-block">
                    <input id="name" type="text" name="gname" required lay-verify="required" autocomplete="off"
                           class="layui-input" value="${goods1.gname}">
                </div>
            </div>
            <%--商品价格--%>
            <div class="layui-col-lg-offset1 layui-col-md10 " style="margin-top:10px;">
                <label class="layui-form-label">价格</label>
                <div class="layui-input-block">
                    <input id="price" type="text" name="gprice" required lay-verify="required" autocomplete="off"
                           class="layui-input" maxlength="40" value="${goods1.gprice}">
                </div>
            </div>
            <%-- 类别 --%>
            <div class="layui-col-lg-offset1 layui-col-md10" style="margin-top:10px;">
                <label class="layui-form-label">类别</label>
                <div class="layui-input-block">
                    <select id="cid" name="gcid" lay-verify="required">
                        <c:forEach items="${categories}" var="category">
                            <c:set var="gcid" value="${goods1.gcid}"/>
                            <c:if test="${category.cname==gcid}">
                                <option value=${category.cname} selected>${category.cname}</option>
                            </c:if>
                            <c:if test="${category.cname!=gcid}">
                                <option value=${category.cname}>${category.cname}</option>
                            </c:if>
                        </c:forEach>

                    </select>
                </div>
            </div>
            <%-- 描述 --%>
            <div class="layui-col-lg-offset1 layui-col-md10" style="margin-top:10px;">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">商品描述</label>
                    <div class="layui-input-block">
                        <textarea id="detail" name="gdetail" placeholder="请输入商品描述"
                                  class="layui-textarea">${goods1.gdetail}</textarea>
                    </div>
                </div>
            </div>
            <%-- 修改按钮 --%>
            <div class="layui-col-lg-offset3 layui-col-md10" style="margin-top:30px;">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="save">保存修改</button>
                </div>
            </div>

        </form>
    </div>
</div>
</body>
</html>
